<template>
    <div class="standard-table">
        <query-form></query-form>
        <div class="h-line"></div>
        <div class="table">
            <Table highlight-row :stripe="false" ref="table" :columns="tableHeader" :data="tableData"></Table>
        </div>
        <pagination :total="total" @change="pageChange"></pagination>
    </div>
</template>

<script>
    import pagination from 'components/commons/pagination'; //分页
    import QueryForm from './QueryForm';  // 查询表单
    export default {
        components: { pagination, QueryForm },
        data(){
            return {
                tableHeader: [
                    { 
                        type: 'index', width: 60, title: '序号', width: 80 
                    }, 
                    { 
                        title: '维修结算单名称', key: 'originalXLSXName'
                    }, 
                    { 
                        title: '上传时间', key: 'updated'
                    }, 
                    { 
                        title: '操作', key: 'action', width: 160, render(h){
                            return h('a', {
                                props: {

                                },
                                style: {

                                },
                                attrs: {
                                    href: 'http://localhost:5143/#/index'
                                }
                            }, '下载源文件')
                        }
                    }
                ],
                tableData: [],
                queryParams: {
                    startdate: '',
                    enddate: '',
                    source: 2,
                    xlsxStatus: '',
                    xlsxPath: 1,
                    statusFix: 0,
                    rows: 10,
                    page: 1
                },
                total: 0
            }
        },
        mounted(){
            // this.init();
        },
        methods: {
            init(){
                if(this.tableData.length !== 0) return;
                this.queryParams.id = '58d8712495596d68f52e5b5a';
                this.getTableData();
            },
            pageChange(params){
                this.queryParams = Object.assign(this.queryParams, params);
                this.getTableData();
            },
            getTableData(){
                this.$ajax(this.$api.statement.maintenaceList, this.queryParams, success => {
                    this.tableData = success.rows;
                    this.total = success.total;
                })
            }
        }
    }
</script>

<style lang="less">
    .standar-table{

    }
</style>
